package org.ioriframework.plugin.maven.console;

import java.util.Date;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.MessageConsole;

public class Console extends MessageConsole {
	
	/**
	 * 控制台任务运行标识，true:任务运行中
	 */
	private boolean isRunning = true;
	
	/**
	 * 强制终止任务标识，true:强制终止
	 */
	private boolean forceTerminate = false;
	
	/**
	 * pom.xml文件路径
	 */
	private String pomPath;
	
	/**
	 * 当前任务的进程ID
	 */
	private Integer pid;
	
	/**
	 * 运行的命令
	 */
	private String command;
	
	/**
	 * 运行的项目名称
	 */
	private String projectName;
	
	/**
	 * 任务开始时间
	 */
	private Date startTime;
	
	/**
	 * 控制台描述
	 */
	private String description;

	public Console(String name, ImageDescriptor imageDescriptor) {
		super(name, imageDescriptor);
	}

	public Console(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) {
		super(name, consoleType, imageDescriptor, autoLifecycle);
	}

	public boolean isRunning() {
		return isRunning;
	}

	public void setRunning(boolean isRunning) {
		this.isRunning = isRunning;
	}

	public boolean isForceTerminate() {
		return forceTerminate;
	}

	public void setForceTerminate(boolean forceTerminate) {
		this.forceTerminate = forceTerminate;
	}

	public String getPomPath() {
		return pomPath;
	}

	public void setPomPath(String pomPath) {
		this.pomPath = pomPath;
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public String getCommand() {
		return command;
	}

	public void setCommand(String command) {
		this.command = command;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
		// 更新控制台描述
		Display.getDefault().syncExec(new Runnable() {
			
			@Override
			public void run() {
				setName(getDescription());
			}
			
		});
	}

}
